package cn.zxl.graduate.web.controller;


import cn.zxl.graduate.domain.Article;
import cn.zxl.graduate.service.IArticleService;
import cn.zxl.graduate.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author bo-feifei
 * @since 2021-11-02
 */
@RestController
@RequestMapping("/article")
public class ArticleController {

    @Autowired
    private IArticleService articleService;

    @GetMapping
    public JsonResult<List<Article>> list(){
        List<Article> article = articleService.list();
        return JsonResult.success(article);
    }

    @GetMapping("/watchNum/{id}")
    public JsonResult<?> watchNum(@PathVariable Long id) {
        Integer watchNum = articleService.watchNumAddByArtId(id);
        return JsonResult.success(watchNum);
    }

    @GetMapping("/likeNum/{id}")
    public JsonResult<?> likeNum(@PathVariable Long id) {
        Integer likeNum = articleService.likeNumAddByArtId(id);
        return JsonResult.success(likeNum);
    }
}

